#!/bin/bash
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=it-arch
export PATH=$ORACLE_HOME/bin:$PATH
filename=`date +%Y-%m-%d`'.bmp'
logname=`date +%Y-%m-%d`'.log'
dump_dir="/backup/backup_dir/"
backdir="dump_dir"
for Schame in GPSUSER
do
/u01/app/oracle/product/11.2.0/db_1/bin/expdp backupuser/back_up123 SCHEMAS=${Schame} dumpfile=${Schame}-${filename} directory=${backdir} log=${Schame}-${logname}
cd ${dump_dir}
tar zcf ${Schame}-$filename.tar.gz ${Schame}-$filename
tar zcf ${Schame}-$logname.tar.gz ${Schame}-$logname
find ${dump_dir} -mtime +7 -name "*.bmp.tar.gz" -exec rm -rf {} \;
find ${dump_dir} -mtime +7 -name "*.log.tar.gz" -exec rm -rf {} \;
done
find ${dump_dir} -name "*.bmp" -exec rm -rf {} \;
find ${dump_dir} -name "*.log" -exec rm -rf {} \;
